<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'a.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

</head>

<body>
	<h1>JSTL core标签库</h1>
	<%-- http://localhost:8888/java-web-demo/jstl/a.jsp?score=88 --%>
	<%
		//request.setAttribute("code", "<input type='text' name='username'/>");
	%>
	<c:set var="code" value="<input type='text' name='username'/>"
		scope="request"></c:set>
	<c:out value="${code }" default="default"></c:out>
	<br />
	<c:out value="${code }" default="default" escapeXml="false"></c:out>
	<br />
	<c:out value="${code2 }" default="default"></c:out>
	<br />
	<c:remove var="code" />
	<c:out value="${code }" default="default"></c:out>
	<br />
	<c:url value="/index.jsp"></c:url>
	<br />
	<c:url value="/index.jsp">
		<c:param name="username" value="张三"></c:param>
	</c:url>
	<br />
	<c:url var="url" scope="request" value="/index.jsp">
		<c:param name="username" value="张三"></c:param>
	</c:url>
	<c:out value="${url }"></c:out>
	<br />
	<c:set var="score" value="${param.score }"></c:set>
	<c:if test="${empty param.score }">
		<c:out value="分数缺失！"></c:out>
	</c:if>
	<c:if test="${not empty param.score }">
		<c:choose>
			<c:when test="${score > 100 || score < 0 }">分数错误：${score }</c:when>
			<c:when test="${score >= 90 }">评分：A</c:when>
			<c:when test="${score >= 80 }">评分：B</c:when>
			<c:when test="${score >= 70 }">评分：C</c:when>
			<c:when test="${score >= 60 }">评分：D</c:when>
			<c:otherwise>评分：E</c:otherwise>
		</c:choose>
	</c:if>
	<br/>
	<c:forEach var="i" begin="1" end="10">
		${i}
	</c:forEach>
	<br/>
	<c:forEach var="i" begin="1" end="10" step="2">
		${i}
	</c:forEach>
	<br/>
	<%
		String[] strs = {"str1","str2"};
		request.setAttribute("strs", strs);
	%>
	<c:forEach items="${requestScope.strs }" var="str">
		${str }
	</c:forEach>
	<br/>
	<c:forEach items="${requestScope.strs }" var="str" varStatus="vs">
		<c:if test="${vs.first }">第一个</c:if>
		<c:if test="${vs.last }">最后一个</c:if>
		第${vs.count }个
		index:${vs.index }
		current:${vs.current }<br/>
	</c:forEach>
	<br/>
</body>
</html>
